﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ScoringClient.ViewModels;

namespace ScoringClient.Views
{
    /// <summary>
    /// Login.xaml 的交互逻辑
    /// </summary>
    public partial class Login : UserControl, IWindow
    {
        public ViewModelBase ViewModel { get; set; }

        public Login()
        {
            ViewModel = new LoginViewModel();
            this.DataContext = ViewModel;
            InitializeComponent();
        }

        private void Login_Click(object sender, RoutedEventArgs e)
        {
            LoginViewModel loginViewModel = ViewModel as LoginViewModel;

            bool? result = true;
            if (loginViewModel.IsMutipleWrongAttempt)
            {
                Identification identification = new Identification();
                identification.Owner = MainWindow.MainWindowHander;
                result = identification.ShowDialog();
            }

            if (result.HasValue && result.Value)
            {
                loginViewModel.Login();
            }
        }

    }
}
